

package com.hazelcast.map.impl.operation;

import com.hazelcast.map.impl.MapDataSerializerHook;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.impl.operationservice.Operation;

import java.io.IOException;

/**
 * Factory for {@link KeyLoadStatusOperation}
 */
public class KeyLoadStatusOperationFactory extends AbstractMapOperationFactory {

    private Throwable exception;

    public KeyLoadStatusOperationFactory() {
    }

    public KeyLoadStatusOperationFactory(String name, Throwable exception) {
        super(name);
        this.exception = exception;
    }

    @Override
    public Operation createOperation() {
        return new KeyLoadStatusOperation(name, exception);
    }

    @Override
    public void writeData(ObjectDataOutput out) throws IOException {
        out.writeString(name);
        out.writeObject(exception);
    }

    @Override
    public void readData(ObjectDataInput in) throws IOException {
        name = in.readString();
        exception = in.readObject();
    }

    @Override
    public int getClassId() {
        return MapDataSerializerHook.KEY_LOAD_STATUS_FACTORY;
    }
}
